<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<title>注册</title>
		<%@include file="/common/header.jsp" %>		
		<link rel="stylesheet" href="${basePath }css/register.css">
	</head>
	<body>
		<%@include file="/common/top.jsp" %>
	
		<div class="_loginFrame">
			<form id="registerForm" action="${basePath }user_register.action" method="POST">
				
				<div class="_login">
					<div class="_login_title">
						<h2>帐号密码注册</h2>
					</div>
					<div class="_login_text">
						<div class="_login_account_img_acc"></div>
						<div class="_login_account">
							<s:textfield id="account" name="user.account"></s:textfield>
						</div>
					</div>
					<div class="_login_text">
						<div class="_login_account_img_pwd"></div>
						<div class="_login_account">
							<s:password id="password" name="user.password"></s:password>
						</div>
					</div>
					<div class="_login_text">
						<div class="_login_account_img_pwd"></div>
						<div class="_login_account">
							<s:password id="repassword"></s:password>
						</div>
					</div>
					<div class="_login_text">
						<div class="_login_account_img_email"></div>
						<div class="_login_email">
							<s:textfield id="email" name="user.email"></s:textfield>
						</div>
					</div>
					<div class="_login_text">
						<div class="_login_account_img_phone"></div>
						<div class="_login_email">
							<s:textfield id="phone" name="user.phone"></s:textfield>
						</div>
					</div>
					<div class="_login_btn">
						<input class="_login_btn_sub" type="button" value="注册" onclick="doSubmit()"/>
					</div>
					<div class="_login_register">
						<h2><a href="${basePath }user/user_toLoginUI.action">返回登录</a></h2>
					</div>
				</div>
				
			</form>
		</div>
		
		
		<script>
			function doSubmit(){
				var accinfo = $('#account').val();		
				if(accinfo.length < 4 || accinfo.length > 16){
					alert('注册帐号长度必须是4-16个字符');
					$('#account').focus();	
					return false;
				}
				
				var pwdinfo = $('#password').val();		
				var repassword = $('#repassword').val();
				if(pwdinfo.length < 4 || pwdinfo.length > 16){
					alert('注册密码长度必须是4-16个字符');
					$('#password').focus();	
					return false;
				}
				if(pwdinfo != repassword){
					alert('两次密码要一致');
					$('#repassword').focus();
					return false;
				}
				//正则表达式校验邮箱
				var emailinfo = $('#email').val();		
				var email=emailinfo.replace(/^\s+|\s+$/g,"").toLowerCase();//去除前后空格并转小写
			    var reg=/^[a-z0-9](\w|\.|-)*@([a-z0-9]+-?[a-z0-9]+\.){1,3}[a-z]{2,4}$/i;
			    if (email.match(reg)==null) {
			      alert("请输入有效的邮箱地址");
			      $('#email').focus();	
			      return false;
			    }
				
				var phoneinfo = $('#phone').val();		
				var reg=/^[0-9]{5,11}$/i;
				if (phoneinfo.match(reg)==null) {
			      alert("请输入有效的手机");
			      $('#phone').focus();	
			      return false;
			    }
				
				//提交表单
				$("#registerForm").submit();
			}
		</script>
		
		<%@include file="/common/footer.jsp" %>
	</body>
</html>